class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * @param str string字符串
     * @return string字符串
     */
    public String setstring(String str) {
        char[] arr = str.toCharArray();
        int cnt = 0;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[i] == arr[j]) {
                    arr[j] = '0';
                    cnt++;
                }
            }
        }
        char[] arr2 = new char[cnt];
        int j = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == '0') {
                continue;
            }
            arr2[j] = arr[i];
            j++;
        }
        String ret = new String(arr2);
        return ret;
    }
}

public class test {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.setstring("BAabBBBBBBB"));
    }
}
